-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect unused-asyncio-dangling-task
(RUF006
) on unused assignments
#9060
Detect unused-asyncio-dangling-task
(RUF006
) on unused assignments
#9060
Conversation
|
else { | ||
continue; | ||
}; | ||
asyncio_dangling_task(checker, value, diagnostics); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job figuring this out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try using typing::analyze::resolve_assignment
here instead? It will also handle AnnAssign
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure how to do it without some refactoring.
I currently use assignment value expression which (if I'm not mistaken) is discarded after processing in resolve_assignment
?
For now I've extended the pattern match to include AnnAssign as done in unnecessary_list_cast - but would gladly change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! A few small comments. Thank you so much for taking this on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again!
unused-asyncio-dangling-task
(RUF006
) on unused assignments
I think this PR has caused ruff to start complaining even when assignments are to globals and nonlocals. Is that intentional? |
@hauntsaninja - probably not — if you share an example I’m happy to ensure it’s fixed in the next release. |
Thanks, filed #9262 ! |
Summary
Fixes #8863 : Detect asyncio-dangling-task (RUF006) when discarding return value
Test Plan
added new two testcases, changed result of an old one that was made more specific